<template>
  <div class="userinfo">
    <!-- 头部 -->
    <my-header title="我的藏宝阁资料" :left="true"></my-header>
    <!-- 头像部分 -->
    <info-header @toUpdate="get_user_info" :user_info="user_info" v-if="isRenderHeader"></info-header>
    <!-- 资料部分 -->
  </div>
</template>
<script>
import MyHeader from "../common/Header";
import InfoHeader from "./components/InfoHeader";
export default {
  name:'UserInfo',
  created() {
    // 发起网络请求
    this.get_user_info();
  },
  data() {
    return {
      isRenderHeader:false,// 阻止头像部分渲染
      user_info:{
        Headpath:"",
        nickName:""
      },
    }
  },
  methods: {
    async get_user_info(){
      // 请求用户数据信息
      const {data:res} = await this.$http.post("/checkToken");
      // 查询到了 赋值给data
      this.user_info.Headpath = res.data.Headpath;
      this.user_info.nickName = res.data.nickName;
      console.log(res.data);
      this.isRenderHeader = true;
    }
  },
  components:{
    MyHeader,
    InfoHeader
  }
}
</script>
<style lang="less" scoped>
  .userinfo{
    padding-top: 0.45rem;
  }
</style>